<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>

import {getCookie} from '@/util/tool'
export default {
  name: 'App',

  data(){
    return {
      backNum: 0
    }
  },

  methods: {
    preventFontSize () {
      if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
          handleFontSize();
      } else {
          if (document.addEventListener) {
              document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
          } else if (document.attachEvent) {
              document.attachEvent("WeixinJSBridgeReady", handleFontSize);
              document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
          }
      }
      function handleFontSize() {
          WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
          WeixinJSBridge.on('menu:setfont', function() {
              WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
          });
      }
    }
  },
  mounted(){
    // if (location.href.indexOf('&from=singlemessage') != -1) {
    //   var url = location.href.replace('&from=singlemessage', '')
    //   location.href = url
    //   return
    // }
    this.preventFontSize()


    
    // 小程序跳H5
    if( getCookie('miniPath')){
   
      window.onpopstate = (event) => {
        
        var state = event.state
        if(!state){
           wx.miniProgram.navigateBack()
           return
        }
         if(!state.page){
           wx.miniProgram.navigateBack()
           return
        }

        if(state.page){
          this.backNum ++
        }

        if(this.backNum >= 2){
          wx.miniProgram.navigateBack()
        }

        console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));
      }
    }
    
  }
}
</script>

<style>
/* @import url('./style/reset.css'); */
html,body{
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body{ 
  font-size: 0.24rem;
   -webkit-text-size-adjust: 100% ;
}
#app{
  width: 100%;
  height: 100%;
     
}
::-webkit-scrollbar  {  
  width: 0;   /* 滚动条宽度 */
  height: 0;  /* 滚动条高度 */
}
::-webkit-input-placeholder { /* WebKit browsers */
    color:#999;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    color:#999;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
    color:#999;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
    color:#999;
}
.amap-logo{display: none !important;}
.amap-copyright{display: none !important;}
</style>
